package net.sk.china.city.mapper;

import java.util.List;
import java.util.Map;

import net.sk.china.city.domain.ArTeam;
import net.sk.china.city.domain.dto.analyse.TeamIdUserCountPair;
import net.sk.china.city.domain.dto.team.TeamSearchDTO;
import net.sk.china.city.domain.dto.team.TeamUpdateDTO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 志愿者队伍Mapper接口
 * 
 * @author ruoyi
 * @date 2024-04-07
 */
@Mapper
public interface ArTeamMapper 
{
    /**
     * 查询志愿者队伍
     * 
     * @param pkId 志愿者队伍主键
     * @return 志愿者队伍
     */
    public ArTeam selectArTeamByPkId(Long pkId);

    /**
     * 查询志愿者队伍列表
     * 
     * @param teamSearchDTO 志愿者队伍
     * @return 志愿者队伍集合
     */
    public Page<ArTeam> selectArTeamList(TeamSearchDTO teamSearchDTO);

    /**
     * 新增志愿者队伍
     *
     * @param teamUpdateDTO 志愿者队伍
     * @return 结果
     */
    public int insertArTeam(TeamUpdateDTO teamUpdateDTO);

    /**
     * 修改志愿者队伍
     *
     * @param teamUpdateDTO 志愿者队伍
     * @return 结果
     */
    public int updateArTeam(TeamUpdateDTO teamUpdateDTO);

    /**
     * 删除志愿者队伍
     * 
     * @param pkId 志愿者队伍主键
     * @return 结果
     */
    public int deleteArTeamByPkId(Long pkId);

    /**
     * 批量删除志愿者队伍
     * 
     * @param pkIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteArTeamByPkIds(Long[] pkIds);

    /**
     * 将用户加入志愿者队伍（在ar_user_team中增加记录）
     * */
    void addUserToTeam(@Param("teamId") Long teamId, @Param("userId") Long userId, @Param("platformId") String platformId);

    /**
    * 查询站点下的所有队伍
    * */
    List<ArTeam> selectAllTeamList(@Param("platformId") String platformId);

    /**
     * 将用户加入到一组志愿者队伍中（加之前记得先删除记录）
     * */
    void addUserToTeamGroup(@Param("teamList") List<ArTeam> teamList, @Param("userId") Long userId);

    /**
     * 将用户从志愿者队伍中移除
     * */
    int removeUserFromTeamGroup(Long userId);

    /**
     * 查询出用户加入的所有队伍
     * */
    List<ArTeam> selectTeamListByUserId(Long userId);

    /**
     * 查询志愿队伍数
     * */
    Long countTeam(String platformId);

    ArTeam selectArTeamByTeamName(String teamName);

    List<ArTeam> selectAllTeam();

    int updateTeamSite(@Param("oldSiteId") Object oldSiteId,
                       @Param("newSiteId") Object newSiteId,
                       @Param("newPlatformId") Object newPlatformId);

    int updateUserTeamPlatformId(@Param("teamId") Long teamId, @Param("platformId") String platformId);

    Map<String, Object> selectPersonCount(List<Long> teamIdList);

    List<TeamIdUserCountPair> countVolunteerCountUnderTeam();

    List<ArTeam> selectTeamList(@Param("teamIdList") List<Long> teamIdList);
}
